Touch up the error message and warnings
authorAlex Crichton <alex@alexcrichton.com>
Mon, 16 May 2016 17:42:29 +0000 (10:42 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Mon, 16 May 2016 17:42:29 +0000 (10:42 -0700)
src/cargo/ops/cargo_rustc/context.rs

index 3660b628ec61ade1826d4efce8e45aa7cf2fb41e..62f9e9818d92387cc19c0258d37afd7004aea064 100644 (file)
@@ -315,21 +315,22 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
 
         let mut ret = Vec::new();
         match *unit.target.kind() {
-            TargetKind::Example | TargetKind::Bin | TargetKind::CustomBuild |
-            TargetKind::Bench | TargetKind::Test => {
+            TargetKind::Example |
+            TargetKind::Bin |
+            TargetKind::CustomBuild |
+            TargetKind::Bench |
+            TargetKind::Test => {
                 ret.push(format!("{}{}", stem, suffix));
             }
             TargetKind::Lib(..) if unit.profile.test => {
                 ret.push(format!("{}{}", stem, suffix));
             }
             TargetKind::Lib(ref libs) => {
-                for lib in libs.iter() {
+                for lib in libs {
                     match *lib {
                         LibKind::Dylib => {
-                            match self.dylib(unit.kind) {
-                                Ok((prefix, suffix)) =>
-                                    ret.push(format!("{}{}{}", prefix, stem, suffix)),
-                                Err(e) => try!(self.config.shell().warn(format!("{}", e)))
+                            if let Ok((prefix, suffix)) = self.dylib(unit.kind) {
+                                ret.push(format!("{}{}{}", prefix, stem, suffix));
                             }
                         }
                         LibKind::Lib |
@@ -341,11 +342,18 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
                         }
                     }
                 }
+                if ret.is_empty() {
+                    if libs.contains(&LibKind::Dylib) {
+                        bail!("cannot produce dylib for `{}` as the target `{}` \
+                               does not support dynamic libraries",
+                              unit.pkg, self.target_triple)
+                    }
+                    bail!("cannot compile `{}` as the target `{}` does not \
+                           support any of the output crate types",
+                          unit.pkg, self.target_triple);
+                }
             }
         }
-        if ret.is_empty() {
-            bail!("no valid targets found")
-        }
         Ok(ret)
     }